//
//  zzqTabBarViewController.m
//  zzqKanBoKe
//
//  Created by ben on 17/2/2.
//  Copyright © 2017年 张增强. All rights reserved.
//

#import "zzqTabBarViewController.h"
#import "zzqTabBar.h"
#import "ZZQNavigationViewController.h"
#import "ZZQLanchViewController.h"

@interface zzqTabBarViewController () <zzqTabBarDelegate>

@property (nonatomic, strong)zzqTabBar * zzqTabbar;

@end

@implementation zzqTabBarViewController

- (zzqTabBar *)zzqTabbar{
    if(!_zzqTabbar){
        _zzqTabbar = [[zzqTabBar alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 49)];
        _zzqTabbar.delegate = self;
    }
    return _zzqTabbar;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self configViewController];
    //添加tabbar
    [self.tabBar addSubview:self.zzqTabbar];
    //tabBar的阴影线
    [[UITabBar appearance] setShadowImage:[UIImage new]];
    [[UITabBar appearance] setBackgroundImage:[UIImage new]];
}

#pragma mark
#pragma mark ==== 添加控制器
- (void)configViewController{
    NSMutableArray * array = [NSMutableArray arrayWithArray:@[@"ZZQMainViewController", @"ZZQMeViewController"]];
    for (NSUInteger i = 0; i < array.count; i++) {
        UIViewController * vc = [[NSClassFromString(array[i]) alloc] init];
        ZZQNavigationViewController * nav = [[ZZQNavigationViewController alloc] initWithRootViewController:vc];
        [array replaceObjectAtIndex:i withObject:nav];
    }
    self.viewControllers = array;
}

- (void)zzqTabBar:(zzqTabBar *)tabBar clickButton:(ZZQItemType)idx{
    if(idx != ZZQItemTypeLaunch){
        self.selectedIndex = idx - ZZQItemTypeLive;
        return;
    }
    ZZQLanchViewController * launchVC = [[ZZQLanchViewController alloc] init];
    [self presentViewController:launchVC animated:YES completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
